package cn.edu.scau.cmi.liuxintong;
import java.awt.event.ActionEvent;
import cn.edu.scau.cmi.liuxintong.simpleFactoryMeyhod.MeatFactory;
import javafx.application.*;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.stage.*;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.scene.web.HTMLEditor;
public class SimpleFactoryMethodClient extends Application {
	public void start(Stage primaryStage) throws Exception {
		 AnchorPane anchorPane = new AnchorPane();
		 Label label = new Label("请输入肉类名称:");
		 TextField textField = new TextField();
		 Button button = new Button("创建");
		 TextArea textArea = new TextArea();
	        textArea.setPrefHeight(380);
	        textArea.setPrefWidth(680);
		 anchorPane.getChildren().addAll(label,textField,button,textArea);
		 button.setOnAction(new EventHandler() {
				public void handle(Event event) {
					 if(textField.getText()!=null&&!textField.getText().isEmpty()) {
						 MeatFactory meat=new MeatFactory();
						 textArea.appendText(meat.getMeet(textField.getText()));
						 textArea.appendText("\n");
				}
				}
			});
		//界面布局
		 AnchorPane.setLeftAnchor(label, 10.0);
		 AnchorPane.setBottomAnchor(label,480.0);//下
		 AnchorPane.setLeftAnchor(textField, 140.0);
		 AnchorPane.setBottomAnchor(textField,470.0);//下
		 AnchorPane.setLeftAnchor(button,350.0);
		 AnchorPane.setBottomAnchor(button,470.0);//下

		 AnchorPane.setLeftAnchor(textArea, 10.0);
		 AnchorPane.setBottomAnchor(textArea,10.0);
		 primaryStage.setScene(new Scene(anchorPane, 700, 500));
	        primaryStage.show();
}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		 launch(args);
	}
}
